package com.zllkj.mm.base;

import androidx.fragment.app.DialogFragment;

import rx.Subscription;
import rx.subscriptions.CompositeSubscription;

public abstract class BaseDialogFragment extends DialogFragment {

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unSubscribe();
    }

    //rx总线
    private CompositeSubscription compositeSubscription = new CompositeSubscription();

    //rx总线里添加订阅
    public void addSubscribe(Subscription subscription) {
        compositeSubscription.add(subscription);
    }

    //rx取消订阅
    public void unSubscribe() {
        if (compositeSubscription != null) {
            compositeSubscription.unsubscribe();
            compositeSubscription = null;
        }
    }

}
